home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / fgl105c.zip / 10-05.C < prev    next >
Text File  |  1991-05-05  |  1KB  |  53 lines

  1. #define VISUAL 0
  2. #define HIDDEN 1
  3.  
  4. main()
  5. {
  6.    int new_mode, old_mode;
  7.    int frame, offset;
  8.    int i;
  9.  
  10.    /* initialize the video environment */
  11.  
  12.    new_mode = fg_bestmode(320,200,2);
  13.    if (new_mode < 0 || new_mode == 12) {
  14.       printf("This program requires a 320 ");
  15.       printf("x 200 color graphics mode.\n");
  16.       exit();
  17.       }
  18.    old_mode = fg_getmode();
  19.    fg_setmode(new_mode);
  20.    fg_allocate(HIDDEN);
  21.  
  22.    /* draw the background in the upper left corner */
  23.  
  24.    fg_setpage(HIDDEN);
  25.    fg_setcolor(1);
  26.    fg_rect(0,95,0,49);
  27.    fg_setcolor(15);
  28.    fg_move(48,25);
  29.    fg_ellipse(20,20);
  30.  
  31.    /* copy it to the center of the visual page */
  32.  
  33.    fg_transfer(0,95,0,49,112,124,HIDDEN,VISUAL);
  34.  
  35.    /* slide the object across the background three times */
  36.  
  37.    fg_setcolor(10);
  38.    for (i = 0; i < 36; i++) {
  39.       frame  = i % 12;
  40.       offset = 10 * frame - 10;
  41.       fg_transfer(0,95,20,29,112,105,HIDDEN,HIDDEN);
  42.       fg_rect(112+offset,131+offset,96,105);
  43.       fg_transfer(112,207,96,105,112,105,HIDDEN,VISUAL);
  44.       fg_waitfor(2);
  45.       }
  46.  
  47.    /* restore the original video mode and return to DOS */
  48.  
  49.    fg_freepage(HIDDEN);
  50.    fg_setmode(old_mode);
  51.    fg_reset();
  52. }
  53.